package com.tuojiahr.tools;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.filter.OncePerRequestFilter;

import com.tuojiahr.domain.TuoJiaHrUser;

/**
 * 说明：
 *
 * @author wang.haibo
 * @date 2012-11-11 上午2:52:30
 */

public class LoginFilter extends OncePerRequestFilter {

	@Override
	protected void doFilterInternal(HttpServletRequest request,
			HttpServletResponse response, FilterChain chain)
			throws ServletException, IOException {
				//判断/adminmgr/*路径下管理员信息是否存在
				//如果存在继续访问，否则进入登陆页面
				TuoJiaHrUser user=(TuoJiaHrUser)request.getSession().getAttribute("user");
				if(user != null){
					chain.doFilter(request, response);
				}else{
					response.sendRedirect(request.getContextPath()+"/admin_index.jsp");
				}
	}

}
